home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
1810
/
1810.xpi
/
chrome
/
showcase.jar
/
content
/
bindings
/
tabbar.xml
Wrap
Extensible Markup Language
|
2010-01-17
|
9KB
|
261 lines
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % tabBrowserDTD SYSTEM "chrome://global/locale/tabbrowser.dtd" >
%tabBrowserDTD;
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % overlayDTD SYSTEM "chrome://showcase/locale/overlay.dtd">
%overlayDTD;
]>
<bindings id="tabBarBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<!-- alltabs-popup binding
This binding relies on the structure of the tabbrowser binding.
Therefore it should only be used as a child of the tabs element.
This binding is exposed as a pseudo-public-API so themes can customize
the tabbar appearance without having to be scriptable
(see globalBindings.xml in Pinstripe for example).
-->
<binding id="tabbar-alltabs-popup"
extends="chrome://global/content/bindings/popup.xml#popup">
<implementation implements="nsIDOMEventListener">
<method name="_menuItemOnCommand">
<parameter name="aEvent"/>
<body><![CDATA[
// note, the tab may not be valid (if after we built the popup
// the tab was closed. but selectedItem setter handles that
// gracefully.
var tabcontainer = getBrowser().mTabContainer;
tabcontainer.selectedItem = aEvent.target.tab;
]]></body>
</method>
<method name="_tabOnAttrModified">
<parameter name="aEvent"/>
<body><![CDATA[
var menuItem = aEvent.target.mCorrespondingMenuitem;
if (menuItem) {
var attrName = aEvent.attrName;
switch (attrName) {
case "label":
case "crop":
case "busy":
case "image":
if (aEvent.attrChange == aEvent.REMOVAL)
menuItem.removeAttribute(attrName);
else
menuItem.setAttribute(attrName, aEvent.newValue);
}
}
]]></body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body><![CDATA[
if (!aEvent.isTrusted)
return;
switch (aEvent.type) {
case "command":
this._menuItemOnCommand(aEvent);
break;
case "DOMAttrModified":
this._tabOnAttrModified(aEvent);
}
]]></body>
</method>
<method name="_onHidingAllTabsPopup">
<body><![CDATA[
// clear out the menu popup and remove the listeners
while (this.hasChildNodes()) {
var menuItem = this.lastChild;
menuItem.removeEventListener("command", this, false);
menuItem.tab.removeEventListener("DOMAttrModified", this, false);
menuItem.tab.mCorrespondingMenuitem = null;
this.removeChild(menuItem);
}
]]></body>
</method>
<method name="_onShowingAllTabsPopup">
<parameter name="aEvent"/>
<body><![CDATA[
// set up the menu popup
var tabcontainer = getBrowser().mTabContainer;
var tabs = tabcontainer.childNodes;
for (var i = 0; i < tabs.length; i++) {
this._addTabToPopup(tabs[i]);
}
]]></body>
</method>
<method name="_addTabToPopup">
<parameter name="curTab"/>
<body><![CDATA[
var menuItem = document.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"menuitem");
if (curTab.selected)
menuItem.setAttribute("selected", "true");
menuItem.setAttribute("class", "menuitem-iconic alltabs-item");
menuItem.setAttribute("label", curTab.label);
menuItem.setAttribute("crop", curTab.getAttribute("crop"));
menuItem.setAttribute("image", curTab.getAttribute("image"));
if (curTab.hasAttribute("busy"))
menuItem.setAttribute("busy", curTab.getAttribute("busy"));
if (curTab.linkedBrowser && curTab.linkedBrowser.contentDocument)
menuItem.setAttribute("tooltiptext", curTab.linkedBrowser.contentDocument.URL);
// XXX todo
// statustext not working yet, since I don't have a menubar
// reuse the menubar statustext logic
var URI = curTab.linkedBrowser.currentURI.spec;
menuItem.setAttribute("statustext", URI);
// Keep some attributes of the menuitem in sync with its
// corresponding tab (e.g. the tab label)
curTab.mCorrespondingMenuitem = menuItem;
curTab.addEventListener("DOMAttrModified", this, false);
menuItem.tab = curTab;
menuItem.addEventListener("command", this, false);
this.appendChild(menuItem);
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshowing"><![CDATA[
if (event.target == this)
this._onShowingAllTabsPopup(event);
]]></handler>
<handler event="popuphiding"><![CDATA[
if (event.target == this)
this._onHidingAllTabsPopup();
]]></handler>
</handlers>
</binding>
<binding id="tabbar-lefttabs-popup"
extends="chrome://showcase/content/bindings/tabbar.xml#tabbar-alltabs-popup">
<implementation>
<method name="_onShowingAllTabsPopup">
<parameter name="aEvent"/>
<body><![CDATA[
// set up the menu popup
var tabcontainer = getBrowser().mTabContainer;
var tabs = tabcontainer.childNodes;
var tabsLeft = ShowcaseCache.calculateHiddenTabsLeft();
if (tabsLeft < 1) {
aEvent.preventDefault();
return;
}
for (var i = tabsLeft - 1; i >= 0; i--) {
this._addTabToPopup(tabs[i]);
}
]]></body>
</method>
</implementation>
</binding>
<binding id="tabbar-righttabs-popup"
extends="chrome://showcase/content/bindings/tabbar.xml#tabbar-alltabs-popup">
<implementation>
<method name="_onShowingAllTabsPopup">
<parameter name="aEvent"/>
<body><![CDATA[
// set up the menu popup
var tabcontainer = getBrowser().mTabContainer;
var tabs = tabcontainer.childNodes;
var tabsRight = ShowcaseCache.calculateHiddenTabsRight();
if (tabsRight < 1) {
aEvent.preventDefault();
return;
}
for (var i = tabs.length - tabsRight; i < tabs.length; i++) {
this._addTabToPopup(tabs[i]);
}
]]></body>
</method>
</implementation>
</binding>
<binding id="left-tooltip"
extends="chrome://global/content/bindings/popup.xml#tooltip">
<implementation>
<field name="mStringBundle">
document.getElementById("bundle_showcaseoverlay")
</field>
<method name="_onShowingLeftTooltip">
<body><![CDATA[
var tabsOnLeft = ShowcaseCache.calculateHiddenTabsLeft();
switch (tabsOnLeft) {
case 0:
this.setAttribute('label', this.mStringBundle.getString("showcaseNoTabsLeftTooltip"));
break;
case 1:
this.setAttribute('label', this.mStringBundle.getString("showcaseTabLeftTooltip"));
break;
default:
this.setAttribute('label', "" + tabsOnLeft + " " + this.mStringBundle.getString("showcaseTabsLeftTooltip"));
break;
}
return true;
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshowing"><![CDATA[
this._onShowingLeftTooltip();
]]></handler>
</handlers>
</binding>
<binding id="right-tooltip"
extends="chrome://global/content/bindings/popup.xml#tooltip">
<implementation>
<field name="mStringBundle">
document.getElementById("bundle_showcaseoverlay")
</field>
<method name="_onShowingRightTooltip">
<body><![CDATA[
var tabsOnRight = ShowcaseCache.calculateHiddenTabsRight();
switch (tabsOnRight) {
case 0:
this.setAttribute('label', this.mStringBundle.getString("showcaseNoTabsRightTooltip"));
break;
case 1:
this.setAttribute('label', this.mStringBundle.getString("showcaseTabRightTooltip"));
break;
default:
this.setAttribute('label', "" + tabsOnRight + " " + this.mStringBundle.getString("showcaseTabsRightTooltip"));
break;
}
return true;
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshowing"><![CDATA[
this._onShowingRightTooltip();
]]></handler>
</handlers>
</binding>
</bindings>